# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=snarf-mitm
pkgver=41.bada142
pkgrel=2
groups=('blackarch' 'blackarch-exploitation' 'blackarch-proxy')
pkgdesc='SMB Man in the Middle Attack Engine / relay suite.'
arch=('any')
url='https://github.com/purpleteam/snarf'
license=('GPL2')
depends=('nodejs')
makedepends=('git')
source=("$pkgname::git+https://github.com/purpleteam/snarf.git")
sha512sums=('SKIP')

pkgver() {
  cd $pkgname

  echo $(git rev-list --count HEAD).$(git rev-parse --short HEAD)
}

package() {
  cd $pkgname

  install -dm 755 "$pkgdir/usr/bin"
  install -dm 755 "$pkgdir/usr/share/$pkgname"

  install -Dm 644 -t "$pkgdir/usr/share/doc/$pkgname/" docs/* CHANGELOG
  install -Dm 644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"

  rm -rf docs CHANGELOG LICENSE

  cp -a * "$pkgdir/usr/share/$pkgname/"

  cat > "$pkgdir/usr/bin/$pkgname" << EOF
#!/bin/sh
cd /usr/share/$pkgname
exec node ./snarf.js "\$@"
EOF

  chmod +x "$pkgdir/usr/bin/$pkgname"
}

